<template>
	<!-- 定时 -->
	<div class="mask" :class="{'none':timeMask==false}">
      <div @click="closetime" class="mask-bg"></div>
      <div class="mask-main task-mask">
        <div class="flex select_form_datetime flex-width-center">
          <input size="16" type="text" v-model="time" readonly class="text-center form_datetime">
        </div>
        <div class="task-mask-btn mt-4">
          <span @click="closetime" class="cursor btn btn-sm btn-secondary">取消</span>
          <span @click="entrytime" class="cursor btn btn-sm btn-success">确定</span>
        </div>
      </div>
    </div>
</template>
<script>
import '../../../static/css/bootstrap-datetimepicker.min.css'
import '../../../static/js/bootstrap-datetimepicker.min.js'

export default {
    name: 'taskTime',
    props: ['timeMask','time'],
    data () {
      return {
        formPage: '',
        time:''
      }
    },
    mounted () {
    	this.dateDefault()
    },
    methods: {
		closetime(){
			this.$emit('closetime')
		}
		entrytime () {
			this.$emit('entrytime')
		},
		dateDefault(){
	      var now = new Date();
	      var Month = (now.getMonth()+1)<10? '0'+ (now.getMonth()+1): (now.getMonth()+1);
	      var day = now.getDate()<10? '0'+ now.getDate(): now.getDate();
	      var hour = now.getHours()<10? '0'+ now.getHours(): now.getHours();
	      var Minutes = now.getMinutes()<10? '0'+ now.getMinutes(): now.getMinutes();
	      var Seconds = now.getSeconds()<10? '0'+ now.getSeconds(): now.getSeconds();

	      var nowday = now.getFullYear()+"-"+Month+"-"+day+' '+hour+':'+Minutes+':'+Seconds;

	      this.time = nowday;
	      $('.form_datetime').datetimepicker({
	        language: 'zh-CN',
	        format: 'yyyy-mm-dd hh:ii:ss',
	        startDate: nowday,
	        weekStart: 1,    //一周从那一天开始，默认值为:0,范围：0-6
	        todayBtn: 1,    //默认值：false，为true时，底部显示today，不选中，为linked时当天日期被选中
	        autoclose: true,    //选择一个日期后是否立即关闭此选择框
	        todayHighlight: 1,  //高亮当前日期
	        startView: 2,     // 日期时间选择器打开之后首先显示的视图，默认值为：2，0:hour,1:day,2:mouth,3:year,4:decade
	        forceParse: 0,    //强制解析文本框的值
	        minuteStep: 2
	       });
	    }
    }
  }
</script>